package com.xsherl.leetcode.solution;

/**
 * @Author: sherl
 * @Date: 2021/5/24 21:05
 */
public class FlipAndInvertImage {

    public int[][] flipAndInvertImage(int[][] A) {
        for (int i = 0; i < A.length; ++i) {
            flipAndInvertRaw(A[i]);
        }
        return A;
    }

    public void flipAndInvertRaw(int[] arr) {
        int len = arr.length, mid = len / 2 + len % 2;
        for (int i = 0; i < mid; ++i) {
            int t = arr[i];
            arr[i] = arr[len - i - 1] ^ 1;
            arr[len - i - 1] = t ^ 1;
        }
    }

}
